<template>

		<view>
			<input class="uni-input py-2" type="text" value="" v-model="studentNum" placeholder="输入学号"/>
			<input class="uni-input py-2" type="text" value="" v-model="userName" placeholder="输入账号"/>
			<input class="uni-input py-2" type="password" value="" v-model="password" placeholder="输入密码"/>
			<input class="uni-input py-2" type="text" value="" v-model="major" placeholder="输入专业"/>
			<view class="py-2 px-3">
				<button class="bg-main text-white" style="border-radius: 50rpx; border: 0;" type="primary" @click="submit" :disabled="disabled">注册</button>
			</view>
		</view>

</template>

<script>
	
	export default {
		data() {
			return {
			studentNum:'',	
			userName:'',
			password:'',
			major:''
			}
		},
		computed:{
			disabled(){
				return this.studentNum == '' || this.userName == '' || this.password == ''
			}
		},
		methods: {
			changeJob(){
				uni.showActionSheet({
				    itemList: sexArray,
				    success:(res) =>{
						this.sex = sexArray[res.tapIndex]
						this.sexIndex = res.tapIndex;
						console.log(this.sex)
				    }
				});
			},
			submit(){
			  this.$R.postNoToken("/system/user/add",{studentnumber:this.studentNum,userName:this.userName,password:this.password,major:this.major}).then(res=>{
				if(res.code == 200){
				   uni.showToast({
				   	title:res.msg,
					icon:'none'
				   })
					setTimeout(()=>{
						uni.navigateTo({
							url:'../login/login'
						})
					},2000) 
				}else{
					uni.showToast({
						title:res.msg,
						icon:'none'
					})
				}
			  })
  				
				
			}		
		}
	}
</script>

<style>

</style>
